{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 多分类问题中的混淆矩阵\n",
    "> 前面的混淆矩阵、精准率-召回率以及ROC都是针对二分类问题，本节扩展到多分类问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "digits = datasets.load_digits()\n",
    "X = digits.data\n",
    "y = digits.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.8, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.\n",
      "  FutureWarning)\n",
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\logistic.py:469: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.\n",
      "  \"this warning.\", FutureWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.93115438108484"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "log_reg = LogisticRegression()\n",
    "log_reg.fit(X_train, y_train)\n",
    "log_reg.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_predict = log_reg.predict(X_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 精准率和召回率支持多分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.93115438108484"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import precision_score # 精准率\n",
    "precision_score(y_test, y_predict, average='micro') # 添加average参数支持多分类问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.93115438108484"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import recall_score # 召回率\n",
    "recall_score(y_test, y_predict, average='micro') # 添加average参数支持多分类问题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 混淆矩阵支持多分类\n",
    "> 手写数字识别是个10分类问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[147,   0,   1,   0,   0,   1,   0,   0,   0,   0],\n",
       "       [  0, 123,   1,   2,   0,   0,   0,   3,   4,  10],\n",
       "       [  0,   0, 134,   1,   0,   0,   0,   0,   1,   0],\n",
       "       [  0,   0,   0, 138,   0,   5,   0,   1,   5,   0],\n",
       "       [  2,   5,   0,   0, 139,   0,   0,   3,   0,   1],\n",
       "       [  1,   3,   1,   0,   0, 146,   0,   0,   1,   0],\n",
       "       [  0,   2,   0,   0,   0,   1, 131,   0,   2,   0],\n",
       "       [  0,   0,   0,   1,   0,   0,   0, 132,   1,   2],\n",
       "       [  1,   9,   2,   3,   2,   4,   0,   0, 115,   4],\n",
       "       [  0,   1,   0,   5,   0,   3,   0,   2,   2, 134]], dtype=int64)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import confusion_matrix\n",
    "confusion_matrix(y_test, y_predict) # 对象先代表预测正确的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "cfm = confusion_matrix(y_test, y_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAECCAYAAADXWsr9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAK50lEQVR4nO3dTYhd9RnH8d8vM6Njxg4REghmQidCsTVCiQzFF8jCiLRV6qYLCwbqZjatRhFEu3HZjYguihBi3VTsImZRpKgFddFFQicvoMlYkNjm1ThdxDFCmLeni3uDk0yae25z/nPuzfP9gJAZb/4+3txvzrkz5/zHESEAN7Y1TQ8AoDxCBxIgdCABQgcSIHQgAUIHEmgsdNs/tf1P25/bfqGpOaqyvdn2R7anbR+1vavpmaqwPWD7sO13m56lCtvrbO+1/Vn7ub6v6Zk6sf1s+zXxqe23bQ83PdOVGgnd9oCkP0j6maS7JP3K9l1NzNKFBUnPRcSPJN0r6Td9MLMk7ZI03fQQXXhN0nsR8UNJP1aPz257k6SnJU1ExN2SBiQ93uxUKzV1RP+JpM8j4nhEzEn6s6THGpqlkog4GxGH2r/+Rq0X4KZmp7o222OSHpG0p+lZqrA9Kmm7pDckKSLmIuJ8s1NVMijpFtuDktZKOtPwPCs0FfomSSeXfXxKPR7NcrbHJW2TdKDZSTp6VdLzkpaaHqSiOyTNSHqz/XZjj+2Rpoe6log4LellSScknZX0dUR80OxUKzUVuq/yub64Ftf2rZLekfRMRMw2Pc//YvtRSV9FxMGmZ+nCoKR7JL0eEdskfSupp79+Y/s2tc5Gt0i6XdKI7SeanWqlpkI/JWnzso/H1IOnO1eyPaRW5G9FxL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Onz5dZN2xsbEi60pltpJeXFxURKx40XFEBxIgdCABQgcSIHQgAUIHEiB0IAFCBxIgdCABQgcSIHQgAUIHEiB0IAFCBxIgdCABQgcSIHQgAUIHEiB0IAFCBxIgdCABQgcSKLYLbIndT0dHR2tf85ILFy4UWbfETp+XLC0tFVl3YGCgyLpzc3NF1i1p//79xdbevn177WvOz89raWmJXWCBjAgdSIDQgQQIHUiA0IEECB1IgNCBBCqFbvtZ20dtf2r7bdvDpQcDUJ+OodveJOlpSRMRcbekAUmPlx4MQH2qnroPSrrF9qCktZLOlBsJQN06hh4RpyW9LOmEpLOSvo6ID0oPBqA+VU7db5P0mKQtkm6XNGL7ias8btL2lO2p+scEcD2qnLo/JOmLiJiJiHlJ+yTdf+WDImJ3RExExETdQwK4PlVCPyHpXttr3bolbYek6bJjAahTlffoByTtlXRI0ift37O78FwAajRY5UER8ZKklwrPAqAQrowDEiB0IAFCBxIgdCABQgcSIHQggWLbPde+aGvdEstKkko8D5I0PFzujt6LFy8WWXdoaKjIuvPz80XWlcptUV3SmTP13xv28MMP68iRI2z3DGRE6EAChA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kUGoX2BlJ/6748PWS/lP7EOX027wSM6+GXpn3+xGx4cpPFgm9G7anImKi0SG60G/zSsy8Gnp9Xk7dgQQIHUigF0Lf3fQAXeq3eSVmXg09PW/j79EBlNcLR3QAhRE6kAChAwkQOpAAoQMJ/BftRrgGc8BMxQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 288x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.matshow(cfm, cmap=plt.cm.gray) # 矩阵中的值映射成一个灰度值\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.        , 0.        , 0.00735294, 0.        , 0.        ,\n",
       "        0.00657895, 0.        , 0.        , 0.        , 0.        ],\n",
       "       [0.        , 0.        , 0.00735294, 0.01342282, 0.        ,\n",
       "        0.        , 0.        , 0.02205882, 0.02857143, 0.06802721],\n",
       "       [0.        , 0.        , 0.        , 0.00671141, 0.        ,\n",
       "        0.        , 0.        , 0.        , 0.00714286, 0.        ],\n",
       "       [0.        , 0.        , 0.        , 0.        , 0.        ,\n",
       "        0.03289474, 0.        , 0.00735294, 0.03571429, 0.        ],\n",
       "       [0.01342282, 0.03496503, 0.        , 0.        , 0.        ,\n",
       "        0.        , 0.        , 0.02205882, 0.        , 0.00680272],\n",
       "       [0.00671141, 0.02097902, 0.00735294, 0.        , 0.        ,\n",
       "        0.        , 0.        , 0.        , 0.00714286, 0.        ],\n",
       "       [0.        , 0.01398601, 0.        , 0.        , 0.        ,\n",
       "        0.00657895, 0.        , 0.        , 0.01428571, 0.        ],\n",
       "       [0.        , 0.        , 0.        , 0.00671141, 0.        ,\n",
       "        0.        , 0.        , 0.        , 0.00714286, 0.01360544],\n",
       "       [0.00671141, 0.06293706, 0.01470588, 0.02013423, 0.01333333,\n",
       "        0.02631579, 0.        , 0.        , 0.        , 0.02721088],\n",
       "       [0.        , 0.00699301, 0.        , 0.03355705, 0.        ,\n",
       "        0.01973684, 0.        , 0.01470588, 0.01428571, 0.        ]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "row_sums = np.sum(cfm, axis=1)\n",
    "err_matrix = cfm / row_sums\n",
    "np.fill_diagonal(err_matrix, 0)\n",
    "err_matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAECCAYAAADXWsr9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAb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3ahh4RY5JekXRS0oSkbyPig9KLAahPlVP3ayU9IOlGSQOS1th+eJHn7bB92PbhmZmZ+jcF8KNVOXW/T9KXEXE6IqYkHZR09/wnRcRwRAxFxNCKFbyZD3SSKkWelHSn7dW2LWmLpNGyawGoU5XX6Ick7Zc0IulY698ZLrwXgBpV+jx6RLwo6cXCuwAohBfTQAKEDiRA6EAChA4kQOhAAoQOJFDkds9TU1NFbkV822231T7zvFK39X3hhReKzJWkl156qcjc66+/vsjcku64444ic3/44YcicyVpeHj5LkfhiA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kQOhAAoQOJEDoQAKEDiRA6EAChA4kQOhAAoQOJOCIqH+ofVrSiYpP75N0pvYlyum2fSV2Xg6dsu/PIuKn8x8sEvpS2D4cEUONLrEE3bavxM7LodP35dQdSIDQgQQ6IfTl+7qKenTbvhI7L4eO3rfx1+gAyuuEIzqAwggdSIDQgQQIHUiA0IEE/gtl6YKc8NkkqgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 288x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.matshow(err_matrix, cmap=plt.cm.gray) # 矩阵中的值映射成一个灰度值\n",
    "plt.show() # 越亮的地方我们预测错地越多"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
